import axios from 'axios'
import { Toast } from 'vant'

axios.defaults.baseURL = 'http://localhost:3000'

axios.interceptors.request.use(function (config) {
  if (localStorage.getItem('Authorization')) {
    config.headers.Authorization = localStorage.getItem('Authorization')
  }
  return config
}, function (error) {
  return Promise.reject(error)
})

axios.interceptors.response.use(function (response) {
  return response
}, function (error) {
  Toast('数据请求失败' + error)
  return Promise.reject(error)
})
export default axios
